# Maintainer: J. Peter Mugaas <jpmugaas@suddenlink.net>

_realname=astroid
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python-${_realname}")
provides=("${MINGW_PACKAGE_PREFIX}-python3-${_realname}")
conflicts=("${MINGW_PACKAGE_PREFIX}-python3-${_realname}")
replaces=("${MINGW_PACKAGE_PREFIX}-python3-${_realname}")
pkgver=2.3.3
pkgrel=1
pkgdesc="Useful miscellaneous modules used by Logilab projects (mingw-w64)"
arch=('any')
url="https://github.com/PyCQA/astroid"
license=('LGPL')
depends=("${MINGW_PACKAGE_PREFIX}-python-six"
         "${MINGW_PACKAGE_PREFIX}-python-lazy-object-proxy"
         "${MINGW_PACKAGE_PREFIX}-python-wrapt"
         "${MINGW_PACKAGE_PREFIX}-python-typed_ast")
makedepends=("${MINGW_PACKAGE_PREFIX}-python-setuptools")
checkdepends=("${MINGW_PACKAGE_PREFIX}-python-dateutil"
              "${MINGW_PACKAGE_PREFIX}-python-pytest"
              "${MINGW_PACKAGE_PREFIX}-python-numpy"
              "${MINGW_PACKAGE_PREFIX}-python-nose"
              "${MINGW_PACKAGE_PREFIX}-python-pytest-runner")
source=(https://github.com/PyCQA/astroid/archive/astroid-${pkgver}.tar.gz)
sha512sums=('cdca9eb7be5619a9bb9bda88c2519bb2708f37ebe51eb4a89966369b722a8fafc18ba860ae565c39ff6afa2dfd2a20395b2f0b762932073c37b249570f86abe5')

prepare() {
  cd "${srcdir}"
   rm -rf "python-build-${CARCH}" | true
   cp -r "${_realname}-${_realname}-${pkgver}" "python-build-${CARCH}"
  # Set version for setuptools_scm
  export SETUPTOOLS_SCM_PRETEND_VERSION=${pkgver}
}

build() {
  msg "Python build for ${CARCH}"  
  cd "${srcdir}/python-build-${CARCH}"
  ${MINGW_PREFIX}/bin/python setup.py build
}

check() {
  msg "Python test for ${CARCH}"
  cd "${srcdir}/python-build-${CARCH}"
  ${MINGW_PREFIX}/bin/pytest || warning "Tests failed"
}

package() {
  cd "${srcdir}/python-build-${CARCH}"
  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
  ${MINGW_PREFIX}/bin/python setup.py install --prefix=${MINGW_PREFIX} \
    --root="${pkgdir}" --optimize=1 --skip-build
}
